<template>
  <ElDrawer v-model="visible" size="65%">
    <ElDescriptions title="请假单详情" direction="vertical" :column="4" :border="true">
      <ElDescriptionsItem label="请假单编号">
        <ElTag>{{ leaveBill.leaveBillCode }}</ElTag></ElDescriptionsItem
      >
      <ElDescriptionsItem label="申请人" min-width="100px">{{
        leaveBill.applier
      }}</ElDescriptionsItem>
      <ElDescriptionsItem label="请假类型" min-width="100px">{{
        leaveBill.leaveType
      }}</ElDescriptionsItem>
      <ElDescriptionsItem label="请假原因" min-width="100px">{{
        leaveBill.reason
      }}</ElDescriptionsItem>
      <ElDescriptionsItem label="请假时间" :span="3"
        >{{ leaveBill.timeStart }}-{{ leaveBill.timeEnd }}</ElDescriptionsItem
      >
      <ElDescriptionsItem label="历史重交次数">{{ leaveBill.resentTimes }}</ElDescriptionsItem>
      <ElDescriptionsItem label="请输入审核意见...">
        <ElInput type="textarea" :rows="3" v-model="leaveAuditDto.auditWord"> </ElInput>
      </ElDescriptionsItem>
    </ElDescriptions>
    <ElButton @click="auditted()" type="primary">同意请假</ElButton>
    <ElButton @click="resent()" type="warning">打回重交</ElButton>
  </ElDrawer>
</template>
<script lang="ts">
import type { LeaveBill } from '@/views/LeaveApply.vue'

/**
 * 页面核心数据结构体说明文档
 *
 *
 */
// import from

export default {
  name: 'LeaveAdvise',
  emits: ['postAuditted'],
  props: {
    sampleP: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      sampleD: 'value',
      leaveBill: {} as LeaveBill,
      visible: false,
      leaveAuditDto: {
        auditWord: 'take care of yourself'
      }
    }
  },
  computed: {
    /* sampleC() {
      return this.sampleD + "--";
    }, */
  },
  created() {},
  mounted() {},
  methods: {
    // sampleM() {},
    show(leaveBill: LeaveBill) {
      this.visible = true
      this.leaveBill = leaveBill
    },
    async auditted() {
      const res = await axios({
        method: 'put',
        url: '/leave/audit/' + this.leaveBill.leaveBillCode,
        data: this.leaveAuditDto
      })
      this.visible = false
      this.$emit('postAuditted', 1)
    },
    async resent() {
      const res = await axios({
        method: 'put',
        url: '/leave/resent/' + this.leaveBill.leaveBillCode
      })
      this.visible = false
      this.$emit('postAuditted', 1)
    }
  },
  watch: {
    // sampleP(n, o) {},
  }
}
</script>

<!--<style scoped>-->
<style lang="scss" scoped></style>
